<script setup>
import {reactive,computed} from 'vue'

const author = reactive({
  name: 'John Doe',
  books: [
    'Vue 2 - Advanced Guide',
    'Vue 3 - Basic Guide',
    'Vue 4 - The Mystery'
  ]
})

//计算属性 是响应式
const aa = computed(()=>{
  console.log("aa计算属性")
  return author.books.length>0 ? 'Yes' :'No'
})
//函数
function ok(){
  let t = 'No'
  if(author.books.length>0) t = 'Yes'
  console.log("ok()调用函数")
  return t
}
</script>

<template>
  <p>Has published books:</p>
  <span>{{ author.books.length > 0 ? 'Yes' : 'No' }}</span>
  <!-- 调用函数 -->
  <p>{{ok()}}</p>
  <!-- 计算属性 表达式 -->
  <p>{{aa}}</p>
</template>
